<template>
  <div class="app-container">
    <div style="display: flex">
      <Find :OriginalFilter="{ static: true }" @Launchform="Launchform5" :formList="formList" @findClicked="findClicked" />
      <Find
        :OriginalFilter="{ static: true }"
        style="margin-left: 15px; margin-top: 20px"
        :searchImg="false"
        @Launchform="Launchform"
        :formList="formList1"
        @findClicked="findClicked1"
      />
    </div>

    <div style="margin-top: 15px">
      <el-card shadow="never" :body-style="{ padding: '13px' }">
        <div slot="header">
          <span style="font-weight: 600; color: red">{{ $t(`Print.InstructionsForPackagingMaterialsToBeOrdered`) }}</span>
        </div>
        <Table
          @checkboxChange="checkboxChange"
          @inputChange="confirmChange11"
          @selectList="selectList"
          :isLoading="isLoading1"
          :tableHeader="tableHeader"
          :tableData="ToBeInstructedTableDate"
          selection
          :TableHeight="27"
        />
        <div>
          <span style="margin-right: 10px; margin-top: 10px; height: 25px">{{ $t(`Print.SelectTotal`) }}</span>
          <el-input
            v-model="inputValueListNum"
            :disabled="true"
            placeholder=""
            size="small"
            clearable
            @change=""
            style="width: 120px; height: 30px; margin-top: 10px"
          />
          <span style="margin-right: 10px; margin-top: 10px; height: 25px; margin-left: 50px">{{ $t(`Print.TotalDispatch`) }}</span>
          <el-input
            v-model="inputValueListN"
            :disabled="true"
            placeholder=""
            size="small"
            clearable
            @change=""
            style="width: 120px; height: 30px; margin-top: 10px"
          />
        </div>
        <PageModule :PageData="{ buttonS: true, total: totalList }" @pageChange="pageChange1" @pageSizeChange="pageSizeChange1" />
      </el-card>
    </div>

    <Find
      :OriginalFilter="{ static: true }"
      @clickNumber1="radio1"
      :searchImg="false"
      @Launchform="Launchform1"
      :formList="formList2"
      @findClicked="findClicked2"
    />
    <div style="margin-top: 10px">
      <el-card shadow="never" :body-style="{ padding: '13px' }">
        <div slot="header" class="f16 mb18">
          <span style="font-weight: 600; color: blue">{{ $t(`Print.OrderDetails`) }}</span>
        </div>
        <Table
          @currentRow="clicktogetdata"
          @inputChange="confirmChange10"
          @selectList="selectList1"
          :isLoading="isLoading"
          :tableHeader="tableHeader2"
          :tableData="OrderedDetailsTableDate"
          selection
          :TableHeight="34"
        />
        <PageModule :PageData="{ buttonS: true, total }" @pageChange="pageChange" @pageSizeChange="pageSizeChange" />
      </el-card>
    </div>

    <!-- 批量改序 -->
    <el-dialog v-model="dialogVisible8" width="50%">
      <div style="display: flex">
        <div style="width: 30%">
          <span style="margin-right: 10px; margin-top: 15px; height: 25px">{{ $t(`Print.OriginalOrderDate`) }}</span>
          <el-input
            v-model="prisce.PurDate"
            :disabled="true"
            placeholder=""
            size="small"
            clearable
            @change=""
            style="width: 120px; height: 30px; margin-top: 10px"
          />
          <p>
            <span style="margin-right: 10px; margin-top: 10px; height: 25px">{{ $t(`Print.OriginalPrice`) }}</span>
            <el-input
              v-model="prisce.Price"
              :disabled="true"
              placeholder=""
              size="small"
              clearable
              @change=""
              style="width: 120px; height: 30px; margin-top: 10px; margin-left: 30px"
            />
          </p>
        </div>

        <div style="width: 30%">
          <span style="margin-right: 10px; margin-top: 15px; height: 25px">{{ $t(`Print.NewOrderDate`) }}</span>
          <el-date-picker
            v-model="newprisce.newPurDate"
            type="date"
            size="small"
            clearable
            style="width: 120px; height: 30px; margin-top: 10px"
            :placeholder="formatCurrentDate(currentDate)"
            format="YYYY/MM/DD"
            value-format="YYYY-MM-DD"
            @change=""
          ></el-date-picker>
          <p>
            <span style="margin-right: 10px; margin-top: 10px; height: 25px">{{ $t(`Print.NewUnitPrice`) }}</span>
            <el-input
              v-model="newprisce.newPrice"
              placeholder=""
              size="small"
              clearable
              @change=""
              style="width: 120px; height: 30px; margin-top: 10px; margin-left: 30px"
            />
          </p>
        </div>
      </div>
      <el-button style="margin-top: 15px; margin-left: 15px" type="primary" size="default" @click="ubDateList">保存</el-button>
    </el-dialog>
  </div>
</template>
<script lang="ts">
import { styleQuery } from '@/api/Control/FactoryControl/FormingPre'
import { ManufacturerQuery } from '@/api/PurchasingDepartment/FactoryPurchasing/MaterialRequisition'
import { packingMaterials } from '@/api/PurchasingDepartment/FactoryPurchasing/PackagingMaterialCategoryDefinition'
import { lotNoListQuery } from '@/api/PurchasingDepartment/FactoryPurchasing/PackagingMaterialsOtherOrder'
import {
  ToBeInstructed,
  CheckTheTapeOrderJob,
  OrderedDetails,
  PurchaseOrderCancellation,
  PurchaseOrderCancellationList
} from '@/api/PurchasingDepartment/FactoryPurchasing/PackingMaterialOrder'
import { GainVendor } from '@/api/WarehouseDepartment/FactoryStorage/ConsumablesIn'
import fileRequest from '@/utils/fileRequest'
import LoginWork from '@/utils/LoginWork'
import { ElMessage } from 'element-plus'
import { defineComponent, onMounted, ref } from 'vue'
import JMessage from '@/utils/JMessage'
export default defineComponent({
  name: 'PackingMaterialOrder'
})
</script>
<script lang="ts" setup>
import { i18n, Jzhcn } from '@/i18n'
const isLoading1 = ref(false)

const checkboxChange = (row: any, list: any) => {
  list.purFlag = list.purFlag === true ? 'Y' : null

  confirmChange11(list)
}

// 带订购明细修改
const confirmChange11 = async (row?: any) => {
  const result = await LoginWork.post<any, any>(`/PackagOrderingOperation/updateNotOrderMaterial`, row)
  if (result.code === 200) {
    ToBeInstructedMethods()
    JMessage.success(result.message)
  } else {
    JMessage.error(result.message)
  }
}

// 日期
const formatCurrentDate = (date?: any) => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  return `${year}-${month}-${day}`
}

const currentDate = ref(new Date())

const newprisce = ref({
  newPrice: '',
  newPurDate: ''
})

const prisce = ref({
  Price: '',
  PurDate: ''
})

const ubDateList = async (row?: any) => {
  if (newprisce.value.newPrice === '' || newprisce.value.newPurDate === '') {
    JMessage.warning('数据不完整')
  } else {
    const result = await LoginWork.post<any, any>(
      `/PackagOrderingOperation/updateReqDateAndUPrice`,
      Object.assign({}, { newPrice: newprisce.value.newPrice, newPurDate: newprisce.value.newPurDate, request: updateTime.value })
    )
    if (result.code === 200) {
      dialogVisible8.value = false
      newprisce.value.newPrice = ''
      newprisce.value.newPurDate = ''
      OrderedDetailsMethods()
      JMessage.success(result.message)
    } else {
      JMessage.error(result.message)
    }
  }
}

const clicktogetdata = (row: any) => {
  prisce.value.Price = row.price
  prisce.value.PurDate = row.reqDate
  updateTime.value = row
  purNoList.value.purNo = row.purNo
  purNoList.value.vendorName = row.vendorName
}

const updateTime = ref({})

// 修改日期/单价
const dialogVisible8 = ref(false)

// 带订购明细修改
const confirmChange10 = async (row?: any) => {
  const result = await LoginWork.post<any, any>(`/PackagOrderingOperation/updateOrderedRemark`, [row])
  if (result.code === 200) {
    OrderedDetailsMethods()
    JMessage.success(result.message)
  } else {
    JMessage.error(result.message)
  }
}

// 生成订购单
const PurchaseOrderCancellationListParms = ref([])

const PurchaseOrderCancellationListMethods = async () => {
  const result = await PurchaseOrderCancellationList(PurchaseOrderCancellationListParms.value)
  if (result.code === 200) {
    OrderedDetailsMethods()
    PurchaseOrderCancellationListParms.value = []
    JMessage.success(result.message)
  } else {
    JMessage.success(result.message)
  }
}

// 订购单取消
const PurchaseOrderCancellationParms = ref([])

const selectList1 = (row: any) => {
  PurchaseOrderCancellationParms.value = row.map((item: any) => {
    return item
  })
  PurchaseOrderCancellationListParms.value = row.map((item: any) => {
    return item
  })
}

const clicktogetdata5 = (row: any) => {
  purNoList.value = row.putNo
}

const purNoList = ref({
  purNo: '',
  vendorName: ''
})

const findClicked2 = async (count: string) => {
  if (count === '订单取消') {
    if (PurchaseOrderCancellationParms.value.length === 0) {
      JMessage.warning('请选择需要取消的订购单')
    } else {
      PurchaseOrderCancellationMethods()
    }
  }
  if (count === '生成订购单') {
    if (PurchaseOrderCancellationListParms.value.length === 0) {
      JMessage.warning('请选择需要生成的订购单')
    } else {
      PurchaseOrderCancellationListMethods()
    }
  }
  if (count === '置空') {
    claerInputValueAndSelectValue1()
  }
  if (count === '修改需求日期/单价') {
    if (prisce.value.PurDate === '') {
      JMessage.warning('请选择需要修改的数据')
    } else {
      dialogVisible8.value = true
    }
  }

  if (count === '导出订购单') {
    if (purNoList.value.purNo === '' || purNoList.value.purNo === null) {
      JMessage.warning('订购单号不可为空')
    } else {
      const res = await fileRequest.post<any, any>(`/PackagOrderingOperation/exportPurchaseOrder`, purNoList.value)
      const link = document.createElement('a') // 利用a标签自定义下载文件名
      let blob = new Blob([res.data]) // 创建Blob对象，设置文件类型
      link.style.display = 'none'
      //设置连接
      link.href = window.URL.createObjectURL(blob)
      const FileName = decodeURI(res.headers['content-disposition'].split(`filename=`)[1])
      link.download = FileName //自定义文件名字
      document.body.appendChild(link)
      //模拟点击事件
      link.click()
      document.body.removeChild(link)
    }
  }

  if (count === '导出订购单(分段/纵)') {
    if (purNoList.value.purNo === '' || purNoList.value.purNo === null) {
      JMessage.warning('订购单号不可为空')
    } else {
      const res = await fileRequest.post<any, any>(`/PackagOrderingOperation/exportPurchaseOrderByLongitudinal`, purNoList.value)
      const link = document.createElement('a') // 利用a标签自定义下载文件名
      let blob = new Blob([res.data]) // 创建Blob对象，设置文件类型
      link.style.display = 'none'
      //设置连接
      link.href = window.URL.createObjectURL(blob)
      const FileName = decodeURI(res.headers['content-disposition'].split(`filename=`)[1])
      link.download = FileName //自定义文件名字
      document.body.appendChild(link)
      //模拟点击事件
      link.click()
      document.body.removeChild(link)
    }
  }

  if (count === '导出订购单(分段/横)') {
    if (purNoList.value.purNo === '' || purNoList.value.purNo === null) {
      JMessage.warning('订购单号不可为空')
    } else {
      const res = await fileRequest.post<any, any>(`/PackagOrderingOperation/exportPurchaseOrderByTransverse`, purNoList.value)
      const link = document.createElement('a') // 利用a标签自定义下载文件名
      let blob = new Blob([res.data]) // 创建Blob对象，设置文件类型
      link.style.display = 'none'
      //设置连接
      link.href = window.URL.createObjectURL(blob)
      const FileName = decodeURI(res.headers['content-disposition'].split(`filename=`)[1])
      link.download = FileName //自定义文件名字
      document.body.appendChild(link)
      //模拟点击事件
      link.click()
      document.body.removeChild(link)
    }
  }

  if (count === '导出订购单(分段/横/预补)') {
    if (purNoList.value.purNo === '' || purNoList.value.purNo === null) {
      JMessage.warning('订购单号不可为空')
    } else {
      const res = await fileRequest.post<any, any>(`/PackagOrderingOperation/exportPurchaseOrderByPrefill`, purNoList.value)
      const link = document.createElement('a') // 利用a标签自定义下载文件名
      let blob = new Blob([res.data]) // 创建Blob对象，设置文件类型
      link.style.display = 'none'
      //设置连接
      link.href = window.URL.createObjectURL(blob)
      const FileName = decodeURI(res.headers['content-disposition'].split(`filename=`)[1])
      link.download = FileName //自定义文件名字
      document.body.appendChild(link)
      //模拟点击事件
      link.click()
      document.body.removeChild(link)
    }
  }
}

const claerInputValueAndSelectValue1 = () => {
  formList2.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
    if (item.type === 'date') {
      item.dateValue = ''
    }
  })
}

const PurchaseOrderCancellationMethods = async () => {
  const result = await PurchaseOrderCancellation(PurchaseOrderCancellationParms.value)
  if (result.code === 200) {
    ToBeInstructedMethods()
    OrderedDetailsMethods()
    PurchaseOrderCancellationParms.value = []
    JMessage.success(result.message)
  } else {
    JMessage.success(result.message)
  }
}

const radio1 = (row: string) => {
  switch (row) {
    case '0': {
      OrderedDetailsParms.value.flag = 0
      break
    }
    case '1': {
      OrderedDetailsParms.value.flag = 1
      break
    }
    case '2': {
      OrderedDetailsParms.value.flag = 2
      break
    }
  }
  OrderedDetailsMethods()
}

const inputValueListN = ref(0)

const isLoading = ref(false)

// 已订购明细查询
const OrderedDetailsParms = ref({
  flag: 0,
  lotNo: '',
  mtlName: '',
  mtlSpec: '',
  pageNum: 0,
  pageSize: 40,
  purDateEnd: '',
  purDateStart: '',
  purNo: '',
  reqDateEnd: '',
  reqDateStart: '',
  shipmentName: '',
  style: '',
  typeName: '',
  typeNo: '',
  vendorName: ''
})

const Launchform1 = (row: any) => {
  OrderedDetailsParms.value.lotNo = row[0].inputValue
  OrderedDetailsParms.value.style = row[1].inputValue
  OrderedDetailsParms.value.purNo = row[2].inputValue
  OrderedDetailsParms.value.vendorName = row[3].selectValue.split(' ')[1]
  OrderedDetailsParms.value.mtlName = row[4].inputValue
  OrderedDetailsParms.value.mtlSpec = row[5].inputValue
  OrderedDetailsParms.value.purDateStart = row[6].dateValue[0]
  OrderedDetailsParms.value.purDateEnd = row[6].dateValue[1]
  OrderedDetailsParms.value.reqDateStart = row[7].dateValue[0]
  OrderedDetailsParms.value.reqDateEnd = row[7].dateValue[1]
  OrderedDetailsMethods()
}

const total = ref(0)

const pageChange = (val: any) => {
  OrderedDetailsParms.value.pageNum = val
  OrderedDetailsMethods()
}

const pageSizeChange = (val: any) => {
  OrderedDetailsParms.value.pageSize = val
  OrderedDetailsMethods()
}

const OrderedDetailsTableDate = ref([])

const OrderedDetailsMethods = async () => {
  isLoading.value = true
  const result = await OrderedDetails(OrderedDetailsParms.value)
  OrderedDetailsTableDate.value = result.lotNoList.map((item: any) => {
    item.change = 'Y'
    item.disableConfirm = true
    return item
  })

  total.value = result.total
  isLoading.value = false
}

// 勾选待订购作业
const CheckTheTapeOrderJobParms = ref<any>({
  date: '',
  request: [],
  vendorName: '',
  vendorNo: ''
})

const Launchform = (row: any) => {
  CheckTheTapeOrderJobParms.value.date = row[1].dateValue
  CheckTheTapeOrderJobParms.value.vendorNo = row[0].selectValue.split(' ')[0]
  CheckTheTapeOrderJobParms.value.vendorName = row[0].selectValue.split(' ')[1]
}

const findClicked1 = (count: string) => {
  if (count === '勾选待订购') {
    if (CheckTheTapeOrderJobParms.value.request.length === 0) {
      JMessage.warning('请勾选需要待订购的数据')
    } else if (CheckTheTapeOrderJobParms.value.vendorNo === '') {
      JMessage.warning('请选择正确的厂商')
    } else if (CheckTheTapeOrderJobParms.value.date === '') {
      JMessage.warning('请选择正确的日期')
    } else {
      CheckTheTapeOrderJobMethods()
    }
  }
}

const CheckTheTapeOrderJobMethods = async () => {
  CheckTheTapeOrderJobParms.value.request.forEach((item: any) => {
    item.purFlag = item.purFlag === true ? 'Y' : null
  })
  const result = await CheckTheTapeOrderJob(CheckTheTapeOrderJobParms.value)
  if (result.code === 200) {
    if (CheckTheTapeOrderJobParms.vlaue !== undefined) {
      CheckTheTapeOrderJobParms.vlaue.request = []
    }

    ToBeInstructedMethods()
    OrderedDetailsMethods()
    JMessage.success(result.message)
  } else {
    JMessage.success(result.message)
  }
}

const selectList = (selectedRows: any[]) => {
  CheckTheTapeOrderJobParms.value.request = selectedRows.map((item: any) => {
    return item
  })

  let totalQty = 0

  selectedRows.forEach((item: any) => {
    totalQty += item.purQty
  })

  inputValueListNum.value = totalQty
}

const inputValueListNum = ref(0)

// 查询
const findClicked = (count: string) => {
  if (count === '置空') {
    claerInputValueAndSelectValue()
  }
}

const claerInputValueAndSelectValue = () => {
  formList.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
  })
}

const Launchform5 = (row: any) => {
  ToBeInstructedParms.value.lotNo = row[0].selectValue
  ToBeInstructedParms.value.style = row[1].selectValue
  ToBeInstructedParms.value.shipmentName = row[2].inputValue
  ToBeInstructedParms.value.typeName = row[3].selectValue.split(' ')[1]
  ToBeInstructedParms.value.typeNo = row[3].selectValue.split(' ')[0]
  ToBeInstructedParms.value.mtlName = row[4].inputValue
  ToBeInstructedParms.value.mtlSpec = row[5].inputValue
  ToBeInstructedMethods()
}

// 包材订购明细查询
const ToBeInstructedParms = ref({
  flag: '',
  lotNo: '',
  mtlName: '',
  mtlSpec: '',
  pageNum: 1,
  pageSize: 40,
  purDateEnd: '',
  purDateStart: '',
  purNo: '',
  reqDateEnd: '',
  reqDateStart: '',
  shipmentName: '',
  style: '',
  typeName: '',
  typeNo: '',
  vendorName: ''
})

const ToBeInstructedTableDate = ref([])

const ToBeInstructedMethods = async () => {
  isLoading1.value = true
  let total = 0
  const result = await ToBeInstructed(ToBeInstructedParms.value)
  ToBeInstructedTableDate.value = result.lotNoList.map((item: any, index: number) => {
    item.purFlag = false
    item.purQty = item.ttlUsage
    total += item.purQty
    item.change = 'Y'
    item.disableConfirm = true
    return item
  })
  inputValueListN.value = total
  totalList.value = result.total
  isLoading1.value = false
}

const totalList = ref(0)

const pageChange1 = (val: any) => {
  ToBeInstructedParms.value.pageNum = val
  ToBeInstructedMethods()
}

const pageSizeChange1 = (val: any) => {
  ToBeInstructedParms.value.pageSize = val
  ToBeInstructedMethods()
}

const EvaluatesTheArrayReturnValue = (ArrayList: any) => {
  return ArrayList.map((item: any, index: any) => {
    return {
      optionKey: index,
      optionValue: item,
      optionLabel: item
    }
  })
}

const packingMaterialsMethods = async () => {
  const result = await packingMaterials()

  let array = result.lotNoList.map((item: any) => {
    delete item.id
    delete item.caluBase
    delete item.sizeFlag
    delete item.purFlag

    return item
  })

  const NewArrayList = array.reduce((arr: any, item: any) => {
    if (item.seqNo && item.typeName) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.seqNo + ' ' + item.typeName)
    }
    return arr
  }, [])

  formList.value[3].selectOptions = EvaluatesTheArrayReturnValue(NewArrayList)
}

const VenderNameList = async () => {
  const result = await ManufacturerQuery()
  const NewArrayList = result.reduce((arr: any, item: any) => {
    if (item.vendorNo && item.vendorName) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.vendorNo + ' ' + item.vendorName)
    }
    return arr
  }, [])

  formList1.value[0].selectOptions = EvaluatesTheArrayReturnValue(NewArrayList)
  formList2.value[3].selectOptions = EvaluatesTheArrayReturnValue(NewArrayList)
}

const styleQueryMethods = async () => {
  let result = await styleQuery()

  formList.value[1].selectOptions = EvaluatesTheArrayReturnValue(result.filter((item: any) => item !== null))
}

onMounted(() => {
  VenderNameList()

  packingMaterialsMethods()

  ToBeInstructedMethods()

  OrderedDetailsMethods()

  styleQueryMethods()

  lotNoListQueryMethods()
})

const totalLo = ref(0)

const lotNoListQueryParms = ref({
  lotNo: '',
  pageSize: 40,
  pageNum: 1
})

const lotNoListQueryMethods = async () => {
  const result = await lotNoListQuery(lotNoListQueryParms.value)
  const NewArrayList = result.lotNoList.reduce((arr: any, item: any) => {
    if (item.lotNo) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.lotNo)
    }
    return arr
  }, [])
  totalLo.value = result.total
  formList.value[0].selectOptions = EvaluatesTheArrayReturnValue(NewArrayList)
}

const handleSizeChange1 = (val: number) => {
  lotNoListQueryParms.value.pageSize = val
  lotNoListQueryMethods()
}
const handleCurrentChange1 = (val: number) => {
  lotNoListQueryParms.value.pageNum = val
  lotNoListQueryMethods()
}

const formList = ref([
  {
    type: 'select',
    selectValue: '',
    selectP: '指令',
    selectLabel: '',
    selectOptions: [],
    PageModule: true,
    total: totalLo,
    handleSizeChange: handleSizeChange1,
    handleCurrentChange: handleCurrentChange1
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '型体',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '请输入品牌',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '类别',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '请输入名称',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入规格',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const formList2 = ref([
  {
    type: 'input',
    inputPlaceholder: '请输入指令',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入型体',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入订购单号',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '厂商',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '请输入材料',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入规格',
    inputValue: '',
    inputLabel: ''
  },
  {
    type: 'date',
    dateLabel: '订购日期',
    dateValue: ''
  },
  {
    type: 'date',
    dateLabel: '需求日期',
    dateValue: ''
  },
  {
    type: 'radio1',
    checkboxLabel: '全部',
    label: '0'
  },
  {
    type: 'radio1',
    checkboxLabel: '未订购',
    label: '1'
  },
  {
    type: 'radio1',
    checkboxLabel: '已订购',
    label: '2'
  },

  {
    type: 'button',
    checkboxLabel: '生成订购单'
  },

  {
    type: 'button',
    checkboxLabel: '修改需求日期/单价'
  },

  {
    type: 'button',
    checkboxLabel: '订单取消'
  },

  {
    type: 'button',
    checkboxLabel: '导出订购单'
  },

  {
    type: 'button',
    checkboxLabel: '导出订购单(分段/横)'
  },
  {
    type: 'button',
    checkboxLabel: '导出订购单(分段/纵)'
  },
  {
    type: 'button',
    checkboxLabel: '导出订购单(分段/横/预补)'
  },

  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const formList1 = ref([
  {
    type: 'select',
    selectValue: '',
    selectP: '厂商',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'dateSingle',
    dateValue: '',
    dateLabel: '交期'
  },
  {
    type: 'button',
    checkboxLabel: '勾选待订购'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const tableHeader = ref([
  {
    label: '指令',
    prop: 'lotNo',
    change: true
  },
  {
    label: '型体',
    prop: 'style',
    change: true
  },
  {
    label: '包材类别',
    prop: 'typeName',
    change: true
  },
  {
    label: '料号',
    prop: 'mtlNo',
    change: true
  },
  {
    label: '材料名称',
    prop: 'mtlName',
    change: true,
    start: true
  },
  {
    label: '规格',
    prop: 'mtlSpec',
    change: true
  },
  {
    label: '单位',
    prop: 'mtlUnit',
    change: true
  },
  {
    label: '用量',
    prop: 'ttlUsage',
    change: true
  },
  {
    label: '订购数量',
    prop: 'purQty'
  },
  {
    label: '订购单价',
    prop: 'price'
  },
  {
    type: 'checkbox',
    label: '客供/通用标记',
    prop: 'purFlag'
  }
])

const tableHeader2 = ref([
  {
    label: '订购单号',
    prop: 'purNo',
    change: true
  },
  {
    label: '订购日期',
    prop: 'purDate',
    change: true
  },
  {
    label: '指令',
    prop: 'lotNo',
    change: true
  },
  {
    label: '厂商',
    prop: 'vendorName',
    change: true
  },
  {
    label: '需求日期',
    prop: 'reqDate',
    change: true
  },
  {
    label: '包材类别',
    prop: 'typeName',
    change: true
  },
  {
    label: '料号',
    prop: 'mtlNo',
    change: true
  },
  {
    label: '材料名称',
    prop: 'mtlName',
    change: true,
    start: true
  },
  {
    label: '规格',
    prop: 'mtlSpec',
    change: true
  },
  {
    label: '单位',
    prop: 'mtlUnit',
    change: true
  },
  {
    label: '订购数量',
    prop: 'purQty',
    change: true
  },
  {
    label: '备注',
    prop: 'purRemark'
  }
])
</script>

<style lang="less" scoped>
.main {
  width: 100%;
  background-color: white;
}

.btns {
  display: flex;
  padding: 10px 35px 5px;
  justify-content: end;

  .bg {
    background-color: #e7e7e7;
    border: 1px solid #e7e7e7;
    color: #000000;
  }
}
</style>
